//
//  TTCustomLuoshiTableViewCell.m
//  TaoTuo
//
//  Created by apple on 2020/11/25.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTCustomLuoshiTableViewCell.h"
#import "TTLuoshiCellView.h"

@interface TTCustomLuoshiTableViewCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) TTLuoshiCellView *luoshiView;
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) UIButton *chooseBtn;

@end

@implementation TTCustomLuoshiTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupSubviews];
        
    }
    return self;
}

/// 选他
- (void)chooseBtnClick
{
    if (self.chooseFinishedBlock) {
        self.chooseFinishedBlock(self.detailModel);
    }
}

- (void)setDetailModel:(TTCustomChooseLuoshiModel *)detailModel
{
    _detailModel = detailModel;
    
    self.luoshiView.detailModel = detailModel;
    
}

- (void)setupSubviews
{
    _bgView = [[UIView alloc] init];
    _bgView.backgroundColor = UIColor.whiteColor;
    _bgView.layer.cornerRadius = 10;
    [self.contentView addSubview:_bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.left.mas_equalTo(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.bottom.equalTo(self.contentView);
    }];
    
    _luoshiView = [[TTLuoshiCellView alloc] init];
    [self.bgView addSubview:_luoshiView];
    [_luoshiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.bgView);
        make.right.equalTo(self.bgView.mas_right);
        make.height.mas_equalTo(100);
    }];
    
    _lineView = [[UIView alloc] init];
    _lineView.backgroundColor = UIColorHex(EDEDED);
    [self.bgView addSubview:_lineView];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.luoshiView.mas_bottom).offset(10);
        make.left.right.equalTo(self.bgView);
        make.height.mas_equalTo(0.5);
    }];
    
    _chooseBtn = [UIButton createButtonWithTitle:@"选择它镶嵌" titleColor:UIColor.whiteColor titleFont:[UIFont boldSystemFontOfSize:15] backgroundColor:UIColorHex(#8B57E6) cornerRadius:18 target:self action:@selector(chooseBtnClick)];
    [self.bgView addSubview:_chooseBtn];
    [_chooseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom).offset(10);
        make.centerX.equalTo(self);
        make.width.mas_equalTo(180);
        make.height.mas_equalTo(36);
    }];
    
}


@end
